package com.kinyx.framework.db.sentence.res.demo.select.sql.method;

import org.junit.Test;

import com.kinyx.framework.db.sentence.CompareType;
import com.kinyx.framework.db.sentence.res.Condition;
import com.kinyx.framework.db.sentence.res.demo.select.SELECT__SUPER;
import com.kinyx.test.entities.impl.DemoEntityR;

public class SELECT_Tester_SQL_join extends SELECT__SUPER {

	@Override
	protected boolean isSQL() { return true; }

	@Test
	public void test111() {
		final String sentence = "SELECT"//
				+ " JOIN T_DEMO demoEntity ON demoEntity.ID = demoEntity1.ID";
		final String str = "SQL: [" + sentence + "], params: []";
		this.test(//
				this.select//
						.join(DemoEntityR.class).on(Condition.eq(DemoEntityR.id, DemoEntityR.id.idx(1))), //
				sentence, str);
	}

	@Test
	public void test112() {
		final String sentence = "SELECT"//
				+ " JOIN T_DEMO demoEntity ON demoEntity.ID = ?";
		final String str = "SQL: [" + sentence + "], params: [foo]";
		this.test(//
				this.select//
						.join(DemoEntityR.class).on(Condition.eq(DemoEntityR.id, "foo")), //
				sentence, str);
	}

	@Test
	public void test121() {
		final String sentence = "SELECT"//
				+ " JOIN T_DEMO demoEntity ON demoEntity.ID = demoEntity1.ID";
		final String str = "SQL: [" + sentence + "], params: []";
		this.test(//
				this.select//
						.join(DemoEntityR.class).on(DemoEntityR.id, CompareType.EQ, DemoEntityR.id.idx(1)), //
				sentence, str);
	}

	@Test
	public void test122() {
		final String sentence = "SELECT"//
				+ " JOIN T_DEMO demoEntity ON demoEntity.ID = ?";
		final String str = "SQL: [" + sentence + "], params: [foo]";
		this.test(//
				this.select//
						.join(DemoEntityR.class).on(DemoEntityR.id, CompareType.EQ, "foo"), //
				sentence, str);
	}

	@Test
	public void test_leftJoin() {
		final String sentence = "SELECT"//
				+ " LEFT JOIN T_DEMO demoEntity ON demoEntity.ID = demoEntity1.ID";
		final String str = "SQL: [" + sentence + "], params: []";
		this.test(//
				this.select//
						.leftJoin(DemoEntityR.class).on(Condition.eq(DemoEntityR.id, DemoEntityR.id.idx(1))), //
				sentence, str);
	}

	@Test
	public void test_rightJoin() {
		final String sentence = "SELECT"//
				+ " RIGHT JOIN T_DEMO demoEntity ON demoEntity.ID = demoEntity1.ID";
		final String str = "SQL: [" + sentence + "], params: []";
		this.test(//
				this.select//
						.rightJoin(DemoEntityR.class).on(Condition.eq(DemoEntityR.id, DemoEntityR.id.idx(1))), //
				sentence, str);
	}

	@Test
	public void test_fullJoin() {
		final String sentence = "SELECT"//
				+ " FULL JOIN T_DEMO demoEntity ON demoEntity.ID = demoEntity1.ID";
		final String str = "SQL: [" + sentence + "], params: []";
		this.test(//
				this.select//
						.fullJoin(DemoEntityR.class).on(Condition.eq(DemoEntityR.id, DemoEntityR.id.idx(1))), //
				sentence, str);
	}

	@Test
	public void test_innerJoin() {
		final String sentence = "SELECT"//
				+ " INNER JOIN T_DEMO demoEntity ON demoEntity.ID = demoEntity1.ID";
		final String str = "SQL: [" + sentence + "], params: []";
		this.test(//
				this.select//
						.innerJoin(DemoEntityR.class).on(Condition.eq(DemoEntityR.id, DemoEntityR.id.idx(1))), //
				sentence, str);
	}

}
